/*
 * Author: kevinlp
 * Created Time:  Mon Nov 21 01:26:58 2011
 * Description: 
 */

#include "Sokcet.h"

socklen_t Ann_Bisten(ssize_t sockfd, const char *host, const char *serv_port, int QLen)
{
    SAI my_addr; 
	socklen_t clilen;
	port = atoi(serv_port);
	bzero(my_addr, sizeof(my_addr));
	my_addr.sin_family = AF_INET;
	my_addr.sin_port = htons(port);
	clilen = sizeof(my_addr);
	if(host == '0')
	{
		my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
	}
	else
	{
		inet_aton(host, &(my_addr.sin_addr))
	}
	if(bind(sockfd, (SA *)&my_addr, sizeof(my_addr)) < 0)
	{
		return ANN_BINDERR;
	}
	if(listen(sockfd, QLen) < 0)
	{
		return ANN_LISTENERR;
	}
	return clilen;
}

ssize_t Ann_Cepollsock()
{
	int on = 1;
	sockfd = socket(AF_INET, SOCK_STREAM, 0);
	if(sockfd < 0)
	{
		err_sys("Create socket error!");
	}
	setnonblock(sockfd);
	setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
	
}
